package Game;

import Java01.Poker;
import Java01.PokerManager;

import java.util.Scanner;

public class GameInit {
    PokerManager pokerManager = new PokerManager();

    Game g = new Game();
        PersonPlayer player = new PersonPlayer() {
            @Override
            public void initID() {
                setID(0);
            }

            @Override
            public void initMoney() {
                setMoney(1000);
            }

            @Override
            public void initName() {
                Scanner sc = new Scanner(System.in);
                System.out.print("请输入您的姓名");
                player.setName(sc.nextLine());
                System.out.println("您好！" + player.getName());
            }

            @Override
            public void pokerPrint() {
                Poker poker = pokerManager.getPoker();
                player.setPoker(poker);
                System.out.println("您的牌是" + poker);
            }
        };
        ComputerGame cg = new ComputerGame();
        ComputerPlayer cPlayer1 = new ComputerPlayer() {

            @Override
            public void initID() {
                setID(1);
            }

            @Override
            public void initMoney() {
                super.initMoney();
                setMoney((r.nextInt(12) + 1) * 100);
            }

            @Override
            public void initName() {
                super.initName();
                setName(s[r.nextInt(9) % 5]);
            }

            @Override
            public void pokerPrint() {
                super.pokerPrint();
                setPoker(pokerManager.getPoker());
            }
        };
        ComputerPlayer cPlayer2 = new ComputerPlayer() {

            @Override
            public void initID() {
                setID(2);
            }

            @Override
            public void initMoney() {
                super.initMoney();
                setMoney((r.nextInt(10) + 1) * 100);
            }

            @Override
            public void initName() {
                super.initName();
                setName(s[r.nextInt(9) % 5]);
            }

            @Override
            public void pokerPrint() {
                super.pokerPrint();
                setPoker(pokerManager.getPoker());
            }
        };
        ComputerPlayer cPlayer3 = new ComputerPlayer() {

            @Override
            public void initID() {
                setID(3);
            }

            @Override
            public void initMoney() {
                super.initMoney();
                setMoney((r.nextInt(15) + 1) * 100);
            }

            @Override
            public void initName() {
                super.initName();
                setName(s[r.nextInt(9) % 5]);
            }

            @Override
            public void pokerPrint() {
                super.pokerPrint();
                setPoker(pokerManager.getPoker());
            }
        };

        public void gameProcessStart(){
            g.begin(player);
            cg.begin(cPlayer1);
            cg.begin(cPlayer2);
            cg.begin(cPlayer3);
        }
        public boolean gameResult(){
            g.CompareCard(player,player,pokerManager);
            boolean flag2 = cg.CompareCard(cPlayer1,player,pokerManager);
            boolean flag3 = cg.CompareCard(cPlayer2,player,pokerManager);
            boolean flag4 = cg.CompareCard(cPlayer3,player,pokerManager);
            System.out.println("您的牌为：" + player.getPoker());
            System.out.println("电脑" + cPlayer1.getID() + "的牌为：" + cPlayer1.getPoker());
            System.out.println("电脑" + cPlayer2.getID() + "的牌为：" + cPlayer2.getPoker());
            System.out.println("电脑" + cPlayer3.getID() + "的牌为：" + cPlayer3.getPoker());
            if (flag2 && flag3 && flag4)
                return false;
            else return true;
        }
}
